﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SGRapidForm.Permission.Service.Interface;
using SGRapidForm.Common;
using SGRapidForm.Permission.Entity;

namespace SGDemo.Web
{
    public partial class HelpList : System.Web.UI.Page
    {

        private IPermissionService _permissionService = ServiceProxyFactory.Create<IPermissionService>("permissionservice");
        protected void Page_Load(object sender, EventArgs e)
        {
            JSManager.RegAjax(Header, this.GetType().BaseType);
            if (!this.IsPostBack)
            {
                rptHelpCategory.DataSource = _permissionService.HelpCategory_GetAll();
                rptHelpCategory.DataBind();
                if (!string.IsNullOrEmpty(this.Request.QueryString["HelpCategoryKeyid"]))
                {
                    rpHelpQuestion.DataSource = _permissionService.Help_FilteredGetAll("").Where(n => n.HelpCategoryKeyid == this.Request.QueryString["HelpCategoryKeyid"].ToString()).ToList();
                    rpHelpQuestion.DataBind();
                    BindLableMethod(this.Request.QueryString["HelpCategoryKeyid"]);
                }
            }

        }
        protected void BindLableMethod(string keyid)
        {
            if (keyid!=""||keyid!=null)
            {
                List<HelpCategory> helpcategoryCell = _permissionService.HelpCategory_GetCategoryAll().Where(n => n.Keyid == keyid).ToList();
               foreach (HelpCategory helpcategorys in helpcategoryCell)
               {
                   foreach (HelpCategory helcategory in _permissionService.HelpCategory_GetCategoryAll().Where(n => n.Keyid == helpcategorys.ParentKeyid))
                   {
                       catogoryNameID.Text = helcategory.HelpCategoryName;
                   
                   }

                   categoryNameChildID.Text = helpcategorys.HelpCategoryName;
               }


            }
        }

        //绑定类别下的子节点
        protected List<HelpCategory> GetHelpByCatogoryKeyid(string parentkeyid)
        {
           
            return _permissionService.HelpCategory_GetByParentKeyid(parentkeyid);
        }

    }
}